<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" v-model="mo" />
        <button  @click="fun ">{{str}}</button>
        <div>{{msg | changeType(mo)}}</div>
        <!-- 原数据：{{mynum}}
        转人民币：{{mynum | changeType("￥")}}
        转美元：{{mynum | changeType("$")}} -->

    </div>
    <script>
        var app = new Vue({
            el:"#app",
            data:{
                mo:"",
                msg:"true",
                str:'美元',
                mynum:1111
            },
            filters: {
                // changeType:function(price,type){
                //     console.log(price,type);
                //     return type + price;
                // }
                changeType:(value,mo) => {
                    return value ? "$" + mo :"￥" + mo
                }
            },
            methods: {
                fun:function(){
                    console.log(this);
                 if(true == this.msg){
                    this.msg=false
                    this.str='人民币'
                 }else{
                     this.msg=true
                     this.str="美元"
                 }
                }
            }

        })
    </script>
    
</body>
</html>